/*
 * FtpContext.h
 *
 *  Created on: 2012-12-28
 *      Author: yangentao@gmail.com
 */

#pragma once;
#include <string>
#include <set>
#include "../yet/net/BaseSocket.h"
#include "../yet/StreamLog.h"
#include "Packet.h"
using namespace std;

namespace ftp {
using namespace yet;

class FtpContext {
public:
	FtpContext();
	virtual ~FtpContext();
public:
	bool connect();
	bool recvControl(Packet* p);
	bool send(string s, bool isOOB);
	bool sendControl(Packet* p);
	bool sendRecvControl(Packet* p);
public:
	string getServerName();
	bool isSupportCommand(string serverCommand);
	vector<string> getNlstItems();
	bool isUnix();
	bool isMsDos();
public:
	LogConnection logConn;
	BaseSocket sock;
	string host;//connect
	u_short port;//connect
	string connectResponse;//connect
	string systData;//syst
	string pwd;//pwd
	set<string> serverCommands;//by help
	string pasvIP;//pasv
	u_short pasvPort;//pasv
	BaseSocket pasvSock;//pasv data connection
	string listData;// list data
	bool listDataOK;//list data recv success
	string nlstData;// list data
	bool nlstDataOK;//list data recv success
private:
	AutoBuffer<char> buf;//for read
};

} /* namespace yet */
